﻿using System;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for Utility
/// </summary>
public class Utility
{
    public Utility()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static int ToInt(string val)
    {
        int result = 0;
        try
        {
            result = int.Parse(val);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return result;
    }

    public static float ToFloat(string val)
    {
        float result = 0;
        try
        {
            result = float.Parse(val);
        }
        catch
        {
        }
        return result;
    }

    public static bool ValidateWithPattern(string str, String pat)
    {

        Regex r = new Regex(pat, RegexOptions.IgnoreCase);
        Match m = r.Match(str);

        if (m.Success)
            return true;

        return false;

    }
}
